home *** CD-ROM | disk | FTP | other *** search
/ Skunkware 98 / Skunkware 98.iso / src / net / omniORB-2.5.0-src.tar.gz / omniORB-2.5.0-src.tar / omniORB_2.5.0 / include / omniORB2 / templates.h < prev   
C/C++ Source or Header  |  1998-03-09  |  27KB  |  936 lines

  1. // -*- Mode: C++; -*-
  2. //                            Package   : omniORB2
  3. // templates.h                Created on: 14/5/96
  4. //                            Author    : Sai Lai Lo (sll)
  5. //
  6. //    Copyright (C) 1996, 1997 Olivetti & Oracle Research Laboratory
  7. //
  8. //    This file is part of the omniORB library
  9. //
  10. //    The omniORB library is free software; you can redistribute it and/or
  11. //    modify it under the terms of the GNU Library General Public
  12. //    License as published by the Free Software Foundation; either
  13. //    version 2 of the License, or (at your option) any later version.
  14. //
  15. //    This library is distributed in the hope that it will be useful,
  16. //    but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. //    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  18. //    Library General Public License for more details.
  19. //
  20. //    You should have received a copy of the GNU Library General Public
  21. //    License along with this library; if not, write to the Free
  22. //    Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  
  23. //    02111-1307, USA
  24. //
  25. //
  26. // Description:
  27. //       *** PROPRIETORY INTERFACE ***
  28.  
  29. /*
  30.   $Log: templates.h,v $
  31.  * Revision 1.15  1998/03/09  17:15:33  ewc
  32.  * New NP_getSlice() function in _Forany template.
  33.  *
  34.  * Revision 1.14  1998/03/05  11:20:21  sll
  35.  * Backoff previous change to Sequence_Array_Var.
  36.  *
  37.   Revision 1.13  1998/03/04 15:07:50  ewc
  38.   Small bug fix to Sequence_Var types
  39.  
  40.  * Revision 1.12  1998/03/04  14:48:34  sll
  41.  * Disambiguous reference to NP_data() by adding the _CORBA_Sequence<T>::
  42.  * prefix.
  43.  *
  44.  * Revision 1.11  1998/01/27  16:11:06  ewc
  45.  * Added support for type any.
  46.  *
  47.   Revision 1.10  1997/12/23 19:37:57  sll
  48.   Removed const T* conversion operator in _CORBA_Array_Var as it is causing
  49.   conversion ambiguity.
  50.   Demote workarounds for older DEC C++ compiler as the bug has been fixed.
  51.  
  52.   Revision 1.9  1997/12/09 20:41:02  sll
  53.   Updated sequence array templates.
  54.  
  55.   Revision 1.8  1997/08/21 22:22:45  sll
  56.   New templates for sequence of array.
  57.  
  58.  * Revision 1.7  1997/05/06  16:11:33  sll
  59.  * Public release.
  60.  *
  61.   */
  62.  
  63. #ifndef __TEMPLATES_H__
  64. #define __TEMPLATES_H__
  65.  
  66. class NetBufferedStream;
  67. class MemBufferedStream;
  68.  
  69.  
  70. template <class T,class T_Helper>
  71. class _CORBA_ObjRef_Member;
  72.  
  73. template <class T,class T_var,class T_member>
  74. class _CORBA_ObjRef_INOUT_arg;
  75.  
  76. template <class T,class T_var,class T_member,class T_Helper>
  77. class _CORBA_ObjRef_OUT_arg;
  78.  
  79. template <class T,class T_Helper>
  80. class _CORBA_ObjRef_Var {
  81. public:
  82.   typedef T* ptr_t;
  83.   inline _CORBA_ObjRef_Var() { pd_objref = T_Helper::_nil(); }
  84.   inline _CORBA_ObjRef_Var(T *p) { pd_objref = p; }
  85.   inline ~_CORBA_ObjRef_Var() { 
  86. #if !defined(__DECCXX) || (__DECCXX_VER >= 50500000)
  87.     if (!T_Helper::is_nil(pd_objref)) T_Helper::release(pd_objref);
  88. #else
  89.     if (!CORBA::is_nil(pd_objref)) CORBA::release(pd_objref);
  90. #endif
  91.   }
  92.   inline _CORBA_ObjRef_Var(const _CORBA_ObjRef_Var<T,T_Helper> &p);
  93.   inline _CORBA_ObjRef_Var(const _CORBA_ObjRef_Member<T,T_Helper>&);
  94.   inline _CORBA_ObjRef_Var<T,T_Helper> &operator= (T * p);
  95.   inline _CORBA_ObjRef_Var<T,T_Helper> &operator= (const _CORBA_ObjRef_Var<T,T_Helper> &p);
  96.  inline _CORBA_ObjRef_Var<T,T_Helper> &operator= (const _CORBA_ObjRef_Member<T,T_Helper>&);
  97.   inline T* operator->() const { return (T*) pd_objref; }
  98.  
  99.   inline operator T* () const { return pd_objref; }
  100.  
  101.   friend class _CORBA_ObjRef_Member<T,T_Helper>;
  102.   friend class _CORBA_ObjRef_INOUT_arg<T,
  103.                                        _CORBA_ObjRef_Var<T,T_Helper>,
  104.                                        _CORBA_ObjRef_Member<T,T_Helper> >;
  105.   friend class _CORBA_ObjRef_OUT_arg<T,
  106.                                      _CORBA_ObjRef_Var<T,T_Helper>,
  107.                                      _CORBA_ObjRef_Member<T,T_Helper>,
  108.                                      T_Helper>;
  109.   
  110. private:
  111.   T* pd_objref;
  112. };
  113.  
  114. template <class T,class T_Helper>
  115. class _CORBA_ObjRef_Member {
  116. public:
  117.   inline _CORBA_ObjRef_Member() { _ptr = T_Helper::_nil(); }
  118.   inline _CORBA_ObjRef_Member(T *p) { _ptr = p; }
  119.   inline _CORBA_ObjRef_Member(const _CORBA_ObjRef_Member<T,T_Helper> &p);
  120.   inline ~_CORBA_ObjRef_Member() { 
  121. #if !defined(__DECCXX) || (__DECCXX_VER >= 50500000)
  122.     if (!T_Helper::is_nil(_ptr)) T_Helper::release(_ptr);
  123. #else
  124.     if (!CORBA::is_nil(_ptr)) CORBA::release(_ptr);
  125. #endif
  126.   }
  127.   inline _CORBA_ObjRef_Member<T,T_Helper> &operator= (T * p);
  128.   inline _CORBA_ObjRef_Member<T,T_Helper> &operator= (const _CORBA_ObjRef_Member<T,T_Helper> &p);
  129.   inline _CORBA_ObjRef_Member<T,T_Helper> &operator= (const _CORBA_ObjRef_Var<T,T_Helper> &p);
  130.  
  131.   inline T* operator->() const { return (T*)_ptr; }
  132.  
  133.   inline size_t NP_alignedSize(size_t initialoffset) const;
  134.   inline void operator>>= (NetBufferedStream &s) const;
  135.   inline void operator<<= (NetBufferedStream &s);
  136.   inline void operator>>= (MemBufferedStream &s) const;
  137.   inline void operator<<= (MemBufferedStream &s);
  138.  
  139.   // The following conversion operators are needed to support the
  140.   // implicit conversion from this type to its T* data member.
  141.   // They are used when this type is used as the rvalue of an expression.
  142.   inline operator T* () const { return _ptr; }
  143.  
  144.   T *_ptr;
  145. };
  146.  
  147. template <class T,class T_var,class T_member>
  148. class _CORBA_ObjRef_INOUT_arg {
  149. public:
  150.   inline _CORBA_ObjRef_INOUT_arg(T*& p) : _data(p) {}
  151.   inline _CORBA_ObjRef_INOUT_arg(T_var& p) : _data(p.pd_objref) {}
  152.   inline _CORBA_ObjRef_INOUT_arg(T_member& p) : _data(p._ptr) {}
  153.   T*& _data;
  154. private:
  155.   _CORBA_ObjRef_INOUT_arg();
  156. };
  157.  
  158. template <class T,class T_var,class T_member,class T_Helper>
  159. class _CORBA_ObjRef_OUT_arg {
  160. public:
  161.   inline _CORBA_ObjRef_OUT_arg(T*& p) : _data(p) {}
  162.   inline _CORBA_ObjRef_OUT_arg(T_var& p) : _data(p.pd_objref) {
  163.     p = T_Helper::_nil();
  164.   }
  165.   inline _CORBA_ObjRef_OUT_arg(T_member& p) : _data(p._ptr) {
  166.     p = T_Helper::_nil();
  167.   }
  168.   T*& _data;
  169. private:
  170.   _CORBA_ObjRef_OUT_arg();
  171. };
  172.  
  173.  
  174. template <class T>
  175. class _CORBA_ConstrType_Fix_Var {
  176. public:
  177.   inline _CORBA_ConstrType_Fix_Var() { }
  178.   inline _CORBA_ConstrType_Fix_Var(T* p) { pd_data = *p; delete p; }
  179.   inline _CORBA_ConstrType_Fix_Var(const _CORBA_ConstrType_Fix_Var<T> &p) {
  180.     pd_data = p.pd_data;
  181.   }
  182.   inline ~_CORBA_ConstrType_Fix_Var() {  }
  183.   inline _CORBA_ConstrType_Fix_Var<T> &operator= (T* p) {
  184.     pd_data = *p;
  185.     delete p;
  186.     return *this;
  187.   }
  188.   inline _CORBA_ConstrType_Fix_Var<T> &operator= (const _CORBA_ConstrType_Fix_Var<T> &p) {
  189.     pd_data = p.pd_data;
  190.     return *this;
  191.   }
  192.   inline _CORBA_ConstrType_Fix_Var<T> &operator= (T p) {
  193.     pd_data = p;
  194.     return *this;
  195.   }
  196.   inline T* operator->() const { return (T*) &pd_data; }
  197.  
  198. #if defined(__GNUG__) && __GNUG__ == 2 && __GNUC_MINOR__ == 7
  199.   inline operator T& () const { return (T&)pd_data; }
  200. #else
  201.   inline operator const T& () const { return pd_data; }
  202.   inline operator T& () { return pd_data; }
  203. #endif
  204.   // This conversion operator is necessary to support the implicit conversion
  205.   // when this var type is used as the IN or INOUT argument of an operation.
  206.  
  207.   // The following coversion operators are needed to support the casting
  208.   // of this var type to a const T* or a T*. The CORBA spec. doesn't say
  209.   // these castings must be supported so they are deliberately left out.
  210.   // In fact, the operator->() can always be used to get to the T*.
  211.   //
  212.   // inline operator const T* () const { return pd_data; }
  213.   // inline operator T* () { return pd_data; }
  214.  
  215. private:
  216.   T pd_data;
  217. };
  218.  
  219. template <class T,class T_var>
  220. class _CORBA_ConstrType_Variable_OUT_arg;
  221.  
  222. template <class T>
  223. class _CORBA_ConstrType_Variable_Var {
  224. public:
  225.   inline _CORBA_ConstrType_Variable_Var() { pd_data = 0; }
  226.   inline _CORBA_ConstrType_Variable_Var(T* p) { pd_data = p; }
  227.   inline _CORBA_ConstrType_Variable_Var(const _CORBA_ConstrType_Variable_Var<T> &p);
  228.   inline ~_CORBA_ConstrType_Variable_Var() {  if (pd_data) delete pd_data; }
  229.   inline _CORBA_ConstrType_Variable_Var<T> &operator= (T* p);
  230.   inline _CORBA_ConstrType_Variable_Var<T> &operator= (const _CORBA_ConstrType_Variable_Var<T> &p);
  231.   inline T* operator->() const { return (T*)pd_data; }
  232.  
  233. #if defined(__GNUG__) && __GNUG__ == 2 && __GNUC_MINOR__ == 7
  234.   inline operator T& () const { return (T&) *pd_data; }
  235. #else
  236.   inline operator const T& () const { return *pd_data; }
  237.   inline operator T& () { return *pd_data; }
  238. #endif
  239.   // This conversion operator is necessary to support the implicit conversion
  240.   // when this var type is used as the IN or INOUT argument of an operation.
  241.  
  242.   // The following coversion operators are needed to support the casting
  243.   // of this var type to a const T* or a T*. The CORBA spec. doesn't say
  244.   // these castings must be supported so they are deliberately left out.
  245.   // In fact, the operator->() can always be used to get to the T*.
  246.   //
  247.   // inline operator const T* () const { return pd_data; }
  248.   // inline operator T* () { return pd_data; }
  249.  
  250.   friend class _CORBA_ConstrType_Variable_OUT_arg<T,_CORBA_ConstrType_Variable_Var<T> >;
  251. private:
  252.   T* pd_data;
  253. };
  254.  
  255.  
  256. template <class T, class T_var>
  257. class _CORBA_ConstrType_Variable_OUT_arg {
  258. public:
  259.   inline _CORBA_ConstrType_Variable_OUT_arg(T*& p) : _data(p) {}
  260.   inline _CORBA_ConstrType_Variable_OUT_arg(T_var& p) : _data(p.pd_data) {
  261.     p = (T*)0;
  262.   }
  263.   T*& _data;
  264. private:
  265.   _CORBA_ConstrType_Variable_OUT_arg();
  266. };
  267.  
  268.  
  269. template <class T,class T_var>
  270. class _CORBA_Sequence_OUT_arg;
  271.  
  272. template <class T,class ElmType>
  273. class _CORBA_Sequence_Var {
  274. public:
  275.   typedef T* ptr_t;
  276.   inline _CORBA_Sequence_Var() { pd_data = 0; }
  277.   inline _CORBA_Sequence_Var(T* p) { pd_data = p; }
  278.   inline _CORBA_Sequence_Var(const _CORBA_Sequence_Var<T,ElmType> &p);
  279.   inline ~_CORBA_Sequence_Var() {  if (pd_data) delete pd_data; }
  280.   inline _CORBA_Sequence_Var<T,ElmType> &operator= (T* p);
  281.   inline _CORBA_Sequence_Var<T,ElmType> &operator= (const _CORBA_Sequence_Var<T,ElmType> &p);
  282.   inline ElmType &operator[] (_CORBA_ULong index) { return (pd_data->_CORBA_Sequence<ElmType>::NP_data())[index]; }
  283.   inline const ElmType &operator[] (_CORBA_ULong index) const {
  284.     return (pd_data->_CORBA_Sequence<ElmType>::NP_data())[index];
  285.   }
  286.   inline T* operator->() const { return (T*)pd_data; }
  287.  
  288. #if defined(__GNUG__) && __GNUG__ == 2 && __GNUC_MINOR__ == 7
  289.   inline operator T& () const { return *pd_data; }
  290. #else
  291.   inline operator const T& () const { return *pd_data; }
  292.   inline operator T& () { return *pd_data; }
  293. #endif
  294.   // This conversion operator is necessary to support the implicit conversion
  295.   // when this var type is used as the IN or INOUT argument of an operation.
  296.  
  297.   // The following coversion operators are needed to support the casting
  298.   // of this var type to a const T* or a T*. The CORBA spec. doesn't say
  299.   // these castings must be supported so they are deliberately left out.
  300.   // In fact, the operator->() can always be used to get to the T*.
  301.   //
  302.   // inline operator const T* () const { return pd_data; }
  303.   // inline operator T* () { return pd_data; }
  304.  
  305.   friend class _CORBA_Sequence_OUT_arg<T,_CORBA_Sequence_Var<T,ElmType> >;
  306.  
  307. private:
  308.   T* pd_data;
  309. };
  310.  
  311. template <class T,class T_slice>
  312. class _CORBA_Sequence_Array_Var {
  313. public:
  314.   typedef T* ptr_t;
  315.   inline _CORBA_Sequence_Array_Var() { pd_data = 0; }
  316.   inline _CORBA_Sequence_Array_Var(T* p) { pd_data = p; }
  317.   inline _CORBA_Sequence_Array_Var(const _CORBA_Sequence_Array_Var<T,T_slice> &p);
  318.   inline ~_CORBA_Sequence_Array_Var() {  if (pd_data) delete pd_data; }
  319.   inline _CORBA_Sequence_Array_Var<T,T_slice> &operator= (T* p);
  320.   inline _CORBA_Sequence_Array_Var<T,T_slice> &operator= (const _CORBA_Sequence_Array_Var<T,T_slice> &p);
  321.   inline T_slice* operator[] (_CORBA_ULong index) { return (T_slice*)((pd_data->NP_data())[index]); }
  322.   inline const T_slice* operator[] (_CORBA_ULong index) const {
  323.     return (const T_slice*)((pd_data->NP_data())[index]);
  324.   }
  325.   inline T* operator->() const { return (T*)pd_data; }
  326.  
  327. #if defined(__GNUG__) && __GNUG__ == 2 && __GNUC_MINOR__ == 7
  328.   inline operator T& () const { return *pd_data; }
  329. #else
  330.   inline operator const T& () const { return *pd_data; }
  331.   inline operator T& () { return *pd_data; }
  332. #endif
  333.   // This conversion operator is necessary to support the implicit conversion
  334.   // when this var type is used as the IN or INOUT argument of an operation.
  335.  
  336.   // The following coversion operators are needed to support the casting
  337.   // of this var type to a const T* or a T*. The CORBA spec. doesn't say
  338.   // these castings must be supported so they are deliberately left out.
  339.   // In fact, the operator->() can always be used to get to the T*.
  340.   //
  341.   // inline operator const T* () const { return pd_data; }
  342.   // inline operator T* () { return pd_data; }
  343.  
  344.   friend class _CORBA_Sequence_OUT_arg<T,_CORBA_Sequence_Array_Var<T,T_slice> >;
  345.  
  346. private:
  347.   T* pd_data;
  348. };
  349.  
  350.  
  351. template <class T, class T_var>
  352. class _CORBA_Sequence_OUT_arg {
  353. public:
  354.   inline _CORBA_Sequence_OUT_arg(T*& p) : _data(p) {}
  355.   inline _CORBA_Sequence_OUT_arg(T_var& p) : _data(p.pd_data) {
  356.     p = (T*)0;
  357.   }
  358.   T*& _data;
  359. private:
  360.   _CORBA_Sequence_OUT_arg();
  361. };
  362.  
  363. template <class T, class T_var>
  364. class _CORBA_Array_OUT_arg;
  365.  
  366. template <class T_Helper,class T>
  367. class _CORBA_Array_Var {
  368. public:
  369.   inline _CORBA_Array_Var () { pd_data = 0; }
  370.   inline _CORBA_Array_Var (T* p) { pd_data = p; }
  371.   inline _CORBA_Array_Var (const _CORBA_Array_Var<T_Helper,T>& p);
  372.   inline ~_CORBA_Array_Var() { if (pd_data) T_Helper::free(pd_data); }
  373.   inline _CORBA_Array_Var<T_Helper,T> &operator= (T* p);
  374.   inline _CORBA_Array_Var<T_Helper,T> &operator= (const _CORBA_Array_Var<T_Helper,T>& p);
  375.   inline T& operator[] (_CORBA_ULong index) { return *(pd_data + index); }
  376.   inline const T& operator[] (_CORBA_ULong index) const { return *( (const T*) (pd_data + index));  }
  377.   inline operator T* () const { return pd_data; }
  378.   // Define the const T* operator() causes conversion operator ambiguity with 
  379.   // some compilers. Should be alright to leave this operator out. If not,
  380.   // reinstate it and #ifdef it with the right compiler specific macro.
  381.   //
  382.   //  inline operator const T* () const { return (const T*) pd_data; }
  383.  
  384.   friend class _CORBA_Array_OUT_arg<T, _CORBA_Array_Var<T_Helper,T> >;
  385.  
  386. private:
  387.   T* pd_data;
  388. };
  389.  
  390. template <class T, class T_var>
  391. class _CORBA_Array_OUT_arg {
  392. public:
  393.   inline _CORBA_Array_OUT_arg(T*& p) : _data(p) {}
  394.   inline _CORBA_Array_OUT_arg(T_var& p) : _data(p.pd_data) {
  395.     p = (T*)0;
  396.   }
  397.   T*& _data;
  398. private:
  399.   _CORBA_Array_OUT_arg();
  400. };
  401.  
  402. template <class T_Helper,class T>
  403. class _CORBA_Array_Forany {
  404. public:
  405.   inline _CORBA_Array_Forany () { pd_data = 0; }
  406.   inline _CORBA_Array_Forany (T* p,_CORBA_Boolean nocopy = 0);
  407.   inline _CORBA_Array_Forany (const _CORBA_Array_Forany<T_Helper,T>& p);
  408.   inline ~_CORBA_Array_Forany() {
  409.     // does not delete the storage of the underlying array
  410.   }
  411.   inline _CORBA_Array_Forany<T_Helper,T> &operator= (T* p);
  412.   inline T& operator[] (_CORBA_ULong index) { return *(pd_data + index); }
  413.   inline const T& operator[] (_CORBA_ULong index) const { return *( (const T*) (pd_data + index)); }
  414.   inline operator T* () const { return pd_data; }
  415.   inline operator const T* () const { return (const T*) pd_data; }
  416.  
  417.   inline T* NP_getSlice() const { return pd_data; }
  418. private:
  419.   T* pd_data;
  420. };
  421.  
  422.  
  423. template <class T,int max>
  424. inline 
  425. _CORBA_Bounded_Sequence<T,max>&
  426. _CORBA_Bounded_Sequence<T,max>::operator= (const _CORBA_Bounded_Sequence<T,max> &s)
  427. {
  428.   _CORBA_Sequence<T>::operator= (s);
  429.   return *this;
  430. }
  431.  
  432. template <class T,int max>
  433. inline 
  434. void
  435. _CORBA_Bounded_Sequence<T,max>::length(_CORBA_ULong len)
  436. {
  437.   if (len > max) {
  438.     _CORBA_bound_check_error();
  439.     // never reach here
  440.   }
  441.   _CORBA_Sequence<T>::length(len);
  442.   return;
  443. }
  444.  
  445. template <class T,class T_slice,class Telm,int dimension,int max>
  446. inline 
  447. _CORBA_Bounded_Sequence_Array<T,T_slice,Telm,dimension,max>&
  448. _CORBA_Bounded_Sequence_Array<T,T_slice,Telm,dimension,max>::operator= (const _CORBA_Bounded_Sequence_Array<T,T_slice,Telm,dimension,max> &s)
  449. {
  450.   _CORBA_Sequence_Array<T,T_slice,Telm,dimension>::operator= (s);
  451.   return *this;
  452. }
  453.  
  454. template <class T,class T_slice,class Telm,int dimension,int max>
  455. inline 
  456. void
  457. _CORBA_Bounded_Sequence_Array<T,T_slice,Telm,dimension,max>::length(_CORBA_ULong len)
  458. {
  459.   if (len > max) {
  460.     _CORBA_bound_check_error();
  461.     // never reach here
  462.   }
  463.   _CORBA_Sequence_Array<T,T_slice,Telm,dimension>::length(len);
  464.   return;
  465. }
  466.  
  467.  
  468. template <class T,int max,int elmSize, int elmAlignment>
  469. inline
  470. _CORBA_Bounded_Sequence_w_FixSizeElement<T,max,elmSize,elmAlignment>&
  471. _CORBA_Bounded_Sequence_w_FixSizeElement<T,max,elmSize,elmAlignment>::operator=(const 
  472. _CORBA_Bounded_Sequence_w_FixSizeElement<T,max,elmSize,elmAlignment>& s) 
  473. {
  474.   _CORBA_Sequence<T>::operator=(s);
  475.   return *this;
  476. }
  477.  
  478. template <class T,int max,int elmSize, int elmAlignment>
  479. inline
  480. _CORBA_ULong
  481. _CORBA_Bounded_Sequence_w_FixSizeElement<T,max,elmSize,elmAlignment>::length() const
  482.   return _CORBA_Sequence<T>::length();
  483. }
  484.  
  485. template <class T,int max,int elmSize, int elmAlignment>
  486. inline
  487. void
  488. _CORBA_Bounded_Sequence_w_FixSizeElement<T,max,elmSize,elmAlignment>::length(_CORBA_ULong len)
  489. {
  490.   if (len > max) {
  491.     _CORBA_bound_check_error();
  492.     // never reach here
  493.   }
  494.   _CORBA_Sequence<T>::length(len);
  495.   return;
  496. }
  497.  
  498. template <class T,class T_slice,class Telm,int dimension,int max,int elmSize, int elmAlignment>
  499. inline
  500. _CORBA_Bounded_Sequence_Array_w_FixSizeElement<T,T_slice,Telm,dimension,max,elmSize,elmAlignment>&
  501. _CORBA_Bounded_Sequence_Array_w_FixSizeElement<T,T_slice,Telm,dimension,max,elmSize,elmAlignment>::operator=(const 
  502. _CORBA_Bounded_Sequence_Array_w_FixSizeElement<T,T_slice,Telm,dimension,max,elmSize,elmAlignment>& s) 
  503. {
  504.   _CORBA_Sequence_Array<T,T_slice,Telm,dimension>::operator=(s);
  505.   return *this;
  506. }
  507.  
  508. template <class T,class T_slice,class Telm,int dimension,int max,int elmSize, int elmAlignment>
  509. inline
  510. _CORBA_ULong
  511. _CORBA_Bounded_Sequence_Array_w_FixSizeElement<T,T_slice,Telm,dimension,max,elmSize,elmAlignment>::length() const
  512.   return _CORBA_Sequence_Array<T,T_slice,Telm,dimension>::length();
  513. }
  514.  
  515. template <class T,class T_slice,class Telm,int dimension,int max,int elmSize, int elmAlignment>
  516. inline
  517. void
  518. _CORBA_Bounded_Sequence_Array_w_FixSizeElement<T,T_slice,Telm,dimension,max,elmSize,elmAlignment>::length(_CORBA_ULong len)
  519. {
  520.   if (len > max) {
  521.     _CORBA_bound_check_error();
  522.     // never reach here
  523.   }
  524.   _CORBA_Sequence_Array<T,T_slice,Telm,dimension>::length(len);
  525.   return;
  526. }
  527.  
  528.  
  529. template <class T,class T_Helper>
  530. inline
  531. _CORBA_ObjRef_Var<T,T_Helper>::_CORBA_ObjRef_Var(const _CORBA_ObjRef_Var<T,T_Helper> &p) 
  532. {
  533.   if (!T_Helper::is_nil(p.pd_objref)) {
  534.     T_Helper::duplicate(p.pd_objref);
  535.     pd_objref = p.pd_objref;
  536.   }
  537.   else
  538.     pd_objref = T_Helper::_nil();
  539. }
  540.  
  541. template <class T,class T_Helper>
  542. inline
  543. _CORBA_ObjRef_Var<T,T_Helper>::_CORBA_ObjRef_Var(const _CORBA_ObjRef_Member<T,T_Helper>& p)
  544. {
  545.   if (!T_Helper::is_nil(p._ptr)) {
  546.     T_Helper::duplicate(p._ptr);
  547.     pd_objref = p._ptr;
  548.   }
  549.   else
  550.     pd_objref = T_Helper::_nil();
  551. }
  552.  
  553. template <class T,class T_Helper>
  554. inline
  555. _CORBA_ObjRef_Var<T,T_Helper> &
  556. _CORBA_ObjRef_Var<T,T_Helper>::operator= (T * p)
  557. {
  558.   if (!T_Helper::is_nil(pd_objref)) T_Helper::release(pd_objref);
  559.   pd_objref = p;
  560.   return *this;
  561. }
  562.  
  563. template <class T,class T_Helper>
  564. inline
  565. _CORBA_ObjRef_Var<T,T_Helper> &
  566. _CORBA_ObjRef_Var<T,T_Helper>::operator= (const _CORBA_ObjRef_Var<T,T_Helper> &p)
  567. {
  568.   if (!T_Helper::is_nil(pd_objref)) T_Helper::release(pd_objref);
  569.   if (!T_Helper::is_nil(p.pd_objref)) {
  570.     T_Helper::duplicate(p.pd_objref);
  571.     pd_objref = p.pd_objref;
  572.   }
  573.   else
  574.     pd_objref = T_Helper::_nil();
  575.   return *this;
  576. }
  577.  
  578. template <class T,class T_Helper>
  579. inline
  580. _CORBA_ObjRef_Var<T,T_Helper> &
  581. _CORBA_ObjRef_Var<T,T_Helper>::operator= (const _CORBA_ObjRef_Member<T,T_Helper>& p)
  582. {
  583.   if (!T_Helper::is_nil(pd_objref)) T_Helper::release(pd_objref);
  584.   if (!T_Helper::is_nil(p._ptr)) {
  585.     T_Helper::duplicate(p._ptr);
  586.     pd_objref = p._ptr;
  587.   }
  588.   else
  589.     pd_objref = T_Helper::_nil();
  590.   return *this;
  591. }
  592.  
  593. template <class T,class T_Helper>
  594. inline 
  595. _CORBA_ObjRef_Member<T,T_Helper>::_CORBA_ObjRef_Member(const _CORBA_ObjRef_Member<T,T_Helper> &p)
  596. {
  597.   if (!T_Helper::is_nil(p._ptr)) {
  598.     T_Helper::duplicate(p._ptr);
  599.     _ptr = p._ptr;
  600.   }
  601.   else
  602.     _ptr = T_Helper::_nil();
  603. }
  604.  
  605. template <class T,class T_Helper>
  606. inline 
  607. _CORBA_ObjRef_Member<T,T_Helper>&
  608. _CORBA_ObjRef_Member<T,T_Helper>::operator= (T * p)
  609. {
  610.   if (!T_Helper::is_nil(_ptr)) T_Helper::release(_ptr);
  611.   _ptr = p;
  612.   return *this;
  613. }
  614.  
  615. template <class T,class T_Helper>
  616. inline 
  617. _CORBA_ObjRef_Member<T,T_Helper>&
  618. _CORBA_ObjRef_Member<T,T_Helper>::operator= (const _CORBA_ObjRef_Member<T,T_Helper> &p)
  619. {
  620.   if (!T_Helper::is_nil(_ptr)) T_Helper::release(_ptr);
  621.   if (!T_Helper::is_nil(p._ptr)) {
  622.     T_Helper::duplicate(p._ptr);
  623.     _ptr = p._ptr;
  624.   }
  625.   else
  626.     _ptr = T_Helper::_nil();
  627.   return *this;
  628. }
  629.  
  630. template <class T,class T_Helper>
  631. inline 
  632. _CORBA_ObjRef_Member<T,T_Helper>&
  633. _CORBA_ObjRef_Member<T,T_Helper>::operator= (const _CORBA_ObjRef_Var<T,T_Helper> &p)
  634. {
  635.   if (!T_Helper::is_nil(_ptr)) T_Helper::release(_ptr);
  636.   if (!T_Helper::is_nil(p.pd_objref)) {
  637.     T_Helper::duplicate(p.pd_objref);
  638.     _ptr = p.pd_objref;
  639.   }
  640.   else
  641.     _ptr = T_Helper::_nil();
  642.   return *this;
  643. }
  644.  
  645. template <class T,class T_Helper>
  646. inline 
  647. size_t 
  648. _CORBA_ObjRef_Member<T,T_Helper>::NP_alignedSize(size_t initialoffset) const 
  649. {
  650.   return T_Helper::NP_alignedSize(_ptr,initialoffset);
  651. }
  652.  
  653. template <class T,class T_Helper>
  654. inline 
  655. void
  656. _CORBA_ObjRef_Member<T,T_Helper>::operator>>= (NetBufferedStream &s) const 
  657. {
  658.   T_Helper::marshalObjRef(_ptr,s);
  659. }
  660.  
  661. template <class T,class T_Helper>
  662. inline 
  663. void
  664. _CORBA_ObjRef_Member<T,T_Helper>::operator<<= (NetBufferedStream &s)
  665. {
  666.   T* _result = T_Helper::unmarshalObjRef(s);
  667.   T_Helper::release(_ptr);
  668.   _ptr = _result;
  669. }
  670.  
  671. template <class T,class T_Helper>
  672. inline 
  673. void
  674. _CORBA_ObjRef_Member<T,T_Helper>::operator>>= (MemBufferedStream &s) const
  675. {
  676.   T_Helper::marshalObjRef(_ptr,s);
  677. }
  678.  
  679. template <class T,class T_Helper>
  680. inline 
  681. void
  682. _CORBA_ObjRef_Member<T,T_Helper>::operator<<= (MemBufferedStream &s)
  683. {
  684.   T* _result = T_Helper::unmarshalObjRef(s);
  685.   T_Helper::release(_ptr);
  686.   _ptr = _result;
  687. }
  688.  
  689. template <class T>
  690. inline 
  691. _CORBA_ConstrType_Variable_Var<T>::_CORBA_ConstrType_Variable_Var(const _CORBA_ConstrType_Variable_Var<T> &p) 
  692. {
  693.   if (!p.pd_data) {
  694.     pd_data = 0;
  695.     return;
  696.   }
  697.   else {
  698.     pd_data = new T;
  699.     if (!pd_data) {
  700.       _CORBA_new_operator_return_null();
  701.       // never reach here
  702.     }
  703.     *pd_data = *p.pd_data;
  704.   }
  705. }
  706.  
  707. template <class T>
  708. inline
  709. _CORBA_ConstrType_Variable_Var<T> &
  710. _CORBA_ConstrType_Variable_Var<T>::operator= (T* p)
  711. {
  712.   if (pd_data) delete pd_data;
  713.   pd_data = p;
  714.   return *this;
  715. }
  716.  
  717. template <class T>
  718. inline
  719. _CORBA_ConstrType_Variable_Var<T> &
  720. _CORBA_ConstrType_Variable_Var<T>::operator= (const _CORBA_ConstrType_Variable_Var<T> &p)
  721. {
  722.   if (p.pd_data) {
  723.     if (!pd_data) {
  724.       pd_data = new T;
  725.       if (!pd_data) {
  726.     _CORBA_new_operator_return_null();
  727.     // never reach here
  728.       }
  729.     }
  730.     *pd_data = *p.pd_data;
  731.   }
  732.   else {
  733.     if (pd_data) delete pd_data;
  734.     pd_data = 0;
  735.   }
  736.   return *this;
  737. }
  738.  
  739. template <class T,class ElmType>
  740. inline
  741. _CORBA_Sequence_Var<T,ElmType> &
  742. _CORBA_Sequence_Var<T,ElmType>::operator= (const _CORBA_Sequence_Var<T,ElmType> &p)
  743. {
  744.   if (p.pd_data) {
  745.     if (!pd_data) {
  746.       pd_data = new T;
  747.       if (!pd_data) {
  748.     _CORBA_new_operator_return_null();
  749.     // never reach here
  750.       }
  751.     }
  752.     *pd_data = *p.pd_data;
  753.   }
  754.   else {
  755.     if (pd_data) delete pd_data;
  756.     pd_data = 0;
  757.   }
  758.   return *this;
  759. }
  760.  
  761. template <class T,class ElmType>
  762. inline 
  763. _CORBA_Sequence_Var<T,ElmType>::_CORBA_Sequence_Var(const _CORBA_Sequence_Var<T,ElmType> &p) 
  764. {
  765.   if (!p.pd_data) {
  766.     pd_data = 0;
  767.     return;
  768.   }
  769.   else {
  770.     pd_data = new T;
  771.     if (!pd_data) {
  772.       _CORBA_new_operator_return_null();
  773.       // never reach here
  774.     }
  775.     *pd_data = *p.pd_data;
  776.   }
  777. }
  778.  
  779. template <class T,class ElmType>
  780. inline
  781. _CORBA_Sequence_Var<T,ElmType> &
  782. _CORBA_Sequence_Var<T,ElmType>::operator= (T* p)
  783. {
  784.   if (pd_data) delete pd_data;
  785.   pd_data = p;
  786.   return *this;
  787. }
  788.  
  789. template <class T,class T_slice>
  790. inline
  791. _CORBA_Sequence_Array_Var<T,T_slice> &
  792. _CORBA_Sequence_Array_Var<T,T_slice>::operator= (const _CORBA_Sequence_Array_Var<T,T_slice> &p)
  793. {
  794.   if (p.pd_data) {
  795.     if (!pd_data) {
  796.       pd_data = new T;
  797.       if (!pd_data) {
  798.     _CORBA_new_operator_return_null();
  799.     // never reach here
  800.       }
  801.     }
  802.     *pd_data = *p.pd_data;
  803.   }
  804.   else {
  805.     if (pd_data) delete pd_data;
  806.     pd_data = 0;
  807.   }
  808.   return *this;
  809. }
  810.  
  811. template <class T,class T_slice>
  812. inline 
  813. _CORBA_Sequence_Array_Var<T,T_slice>::_CORBA_Sequence_Array_Var(const _CORBA_Sequence_Array_Var<T,T_slice> &p) 
  814. {
  815.   if (!p.pd_data) {
  816.     pd_data = 0;
  817.     return;
  818.   }
  819.   else {
  820.     pd_data = new T;
  821.     if (!pd_data) {
  822.       _CORBA_new_operator_return_null();
  823.       // never reach here
  824.     }
  825.     *pd_data = *p.pd_data;
  826.   }
  827. }
  828.  
  829. template <class T,class T_slice>
  830. inline
  831. _CORBA_Sequence_Array_Var<T,T_slice> &
  832. _CORBA_Sequence_Array_Var<T,T_slice>::operator= (T* p)
  833. {
  834.   if (pd_data) delete pd_data;
  835.   pd_data = p;
  836.   return *this;
  837. }
  838.  
  839.  
  840. template <class T_Helper,class T>
  841. inline
  842. _CORBA_Array_Var<T_Helper,T>::_CORBA_Array_Var (const _CORBA_Array_Var<T_Helper,T >& p) 
  843. {
  844.   if (!p.pd_data) {
  845.     pd_data = 0;
  846.   }
  847.   else {
  848.     pd_data = T_Helper::dup(p.pd_data);
  849.     if (!pd_data) {
  850.       _CORBA_new_operator_return_null();
  851.     }
  852.   }
  853. }
  854.  
  855. template <class T_Helper,class T>
  856. inline 
  857. _CORBA_Array_Var<T_Helper,T>&
  858. _CORBA_Array_Var<T_Helper,T>::operator= (T* p) 
  859. {
  860.   if (pd_data) T_Helper::free(pd_data);
  861.   pd_data = p;
  862.   return *this;
  863. }
  864.  
  865. template <class T_Helper,class T>
  866. inline 
  867. _CORBA_Array_Var<T_Helper,T>&
  868. _CORBA_Array_Var<T_Helper,T>::operator= (const _CORBA_Array_Var<T_Helper,T>& p) 
  869. {
  870.   if (pd_data) {
  871.     T_Helper::free(pd_data);
  872.   }
  873.   if (p.pd_data) {
  874.     pd_data = T_Helper::dup(p.pd_data);
  875.     if (!pd_data) {
  876.       _CORBA_new_operator_return_null();
  877.       // never reach here
  878.     }
  879.   }
  880.   else {
  881.     pd_data = 0;
  882.   }
  883.   return *this;
  884. }
  885.  
  886. template <class T_Helper,class T>
  887. inline 
  888. _CORBA_Array_Forany<T_Helper,T>::_CORBA_Array_Forany (T* p,_CORBA_Boolean nocopy)
  889. {
  890.   if (nocopy) {
  891.     pd_data = p;
  892.   }
  893.   else {
  894.     if (p) {
  895.       pd_data = T_Helper::dup(p);
  896.       if (!pd_data) {
  897.     _CORBA_new_operator_return_null();
  898.     // never reach here
  899.       }
  900.     }
  901.     else {
  902.       pd_data = 0;
  903.     }
  904.   }
  905. }
  906.  
  907.  
  908. template <class T_Helper,class T>
  909. inline 
  910. _CORBA_Array_Forany<T_Helper,T>&
  911. _CORBA_Array_Forany<T_Helper,T>::operator= (T* p) 
  912. {
  913.   pd_data = p;
  914.   return *this;
  915. }
  916.  
  917. template <class T_Helper,class T>
  918. inline 
  919. _CORBA_Array_Forany<T_Helper,T>::_CORBA_Array_Forany (const _CORBA_Array_Forany<T_Helper,T>& p)
  920. {
  921.   if (!p.pd_data) {
  922.     pd_data = 0;
  923.   }
  924.   else {
  925.     pd_data = T_Helper::dup(p.pd_data);
  926.     if (!pd_data) {
  927.       _CORBA_new_operator_return_null();
  928.     }
  929.   }
  930. }
  931.  
  932. #endif // __TEMPLATES_H__
  933.  
  934.